<template>
	<view>
		<view class="mainpadding2">
			<view class="mainpadding_top ffffff radius flexleft" v-for="(item,index) in ydjdList" :key="index">
				<image :src="item.shoptable.image_text" class="margin_right3 goodsImg" mode=""></image>
				<view class="flexcolumnbet" style="width: 100%;min-height: 157rpx;">
					<view class="xiaohei titletext">{{item.shoptable.num}}
					<text class="xiaolan margin_left1" style="font-size: 26rpx;">*{{item.house_num}}閒</text></view>
					<text v-for="(ite,itedex) in item.gg_content_text" :key="itedex">
						<text class="xiaohui" style="color: #00a0e9;" v-for="(it,itdex) in ite.content" :key="itdex">
							<text class="margin_right1" v-show="it.num!=0">{{it.name}}*{{it.num}}</text>
						</text>
					</text>
					<view class="xiaohong "><text v-show="item.adult_num!=0" class="margin_right1">客戶{{item.adult_num}}人</text><text v-show="item.old_num!=0" class="margin_right1">老人{{item.old_num}}人</text><text v-show="item.child_num!=0">小孩{{item.child_num}}人</text></view>
					<view class="xiaohong " v-if="item.zs_type!=1 && item.zs_type!=2">入住 {{item.start_date_text}}<br>離開 {{item.end_date_text}}，共{{item.days}}晚</view>
					<view class="xiaohong " v-if="item.zs_type==2">入住 {{item.start_date_text}}<br>離開 {{item.end_date_text}}</view>
					<view class="flexbetween" style="width: 100%;">
						<view class="text_six huang_text">${{item.pay_price}}</view>
						<view class="flexleft" @click="removeCart(item.id)">
							<u-icon name="trash" class="margin_right1" color="#777" size="18"></u-icon>
							<view class="text_b color_san">刪除</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="posibottom mainpadding">
			<view class="submitbtn" @click="submit">結帳：{{returnHotelprice()}}</view>
		</view> -->
		<view class="footerBox">
			<view class="footerPirce flexbetween">
				<view class="flexleft paddingtb padding_left3">
					<view>
						<text class="text_j color_ling">合計：</text>
						<text class="totalPrice">$</text>
						<text class="totalPrice" style="font-size: 36rpx;">{{returnHotelprice()}}</text>
					</view>
				</view>
				<view class="flexleft">
					<view class="settlement" @click="submit">結帳</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				ydjdList: [],
				rznum: 0,
				start_date: "",
				end_date: "",
				zs_type:1,
				allnum:0,
				yhlxid:"",
				is_yc:0,
				adult_num:"",
				old_num:"",
				child_num:"",
				shop_id: uni.getStorageSync("shop_id"), //店鋪id
			}
		},
		onLoad(options) {
			let data = JSON.parse(decodeURIComponent(options.msg));
			this.rznum = data.rznum
			this.start_date = data.start_date
			this.end_date = data.end_date
			this.zs_type = data.zs_type
			this.allnum = data.allnum
			this.yhlxid = data.yhlxid
			this.is_yc = data.is_yc
			this.adult_num = data.adult_num
			this.old_num = data.old_num
			this.child_num = data.child_num
		},
		onShow() {
			this.getgwc()
		},
		methods: {
			getgwc(){
				httpRequest.request("/api/hotel/orderIndex", "GET", {
					shop_id: this.shop_id,
					data_type:1
				}).then(res => {
					this.ydjdList = res.data
				})
			},
			returnHotelprice() {
				let price = 0
				this.ydjdList.forEach(item => {
					price = Number(item.pay_price) + Number(price)
				})
				return price
			},
			removeCart(id) {
				this.http.request("/api/hotel/delOrderCart", 'GET', {
					id
				}).then(res => {
					this.http.toast(res.msg)
					if (res.code == 1) {
						this.getgwc()
					}
				})
			},
			submit() {
				this.http.request("/api/hotel/orderPayInfo", 'GET', {
					shop_id: this.shop_id,
				}).then(res => {
					uni.navigateTo({
						url: "/pages_index/payment?msg=" + encodeURIComponent(JSON.stringify({
							id:res.data.pay_order_no,
							paymoney: res.data.pay_price,
							order_type: 6,
							shop_id: this.shop_id,
							call_no: "暫時寫死"
						}))
					})
				})
				return false
				let data = []
				this.ydjdList.forEach(item => {
					data.push({
						hotel_id: item.hotelinfo.id,
						gg_content: item.orderobj.gg_content,
						gg_price: item.gg_price
					})
				})
				httpRequest.request('/api/hotel/create_order', 'POST', {
					hotel_data: data,
					adult_num: this.adult_num,
					old_num: this.old_num,
					child_num: this.child_num,
					start_date: this.start_date,
					end_date: this.zs_type==2?this.returnxxjsTime(this.end_date,this.dataAll.xxtime):this.end_date,
					zs_type:this.zs_type,
					is_yc:this.is_yc,
					allnum:this.allnum,
					shop_id: this.shop_id
				}).then(res => {
					if(res.code==1){
						let item = res.data
						uni.navigateTo({
							url: "/pages_index/payment?msg=" + encodeURIComponent(JSON.stringify({
								id: item.id,
								paymoney: item.pay_price,
								order_type: 6,
								shop_id: item.shop_id,
								call_no: "暫時寫死"
							}))
						})
					}else{
						httpRequest.toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goodsImg {
		width: 227rpx;
		height: 227rpx;
		min-width: 227rpx;
		position: relative;

		image {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}

	}
	.footerBox {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: fixed;
		left: 0;
		bottom: 40rpx;
	
		.footerPirce {
			width: 708rpx;
			height: 101rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 53rpx 53rpx 53rpx 53rpx;
		}
	
		.cart {
			width: 40.5rpx;
			height: 42.58rpx;
			background-image: url("@/static/images/index/cart_num.png");
			background-size: 100% 100%;
			position: relative;
		}
	
		.num {
			width: 35rpx;
			height: 35rpx;
			line-height: 35rpx;
			text-align: center;
			background: #FF5C00;
			border-radius: 50%;
			position: absolute;
			right: -20rpx;
			top: -20rpx;
			font-size: 17rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	
		.line_r {
			width: 0;
			height: 42rpx;
			border-right: 2rpx dashed rgba(0, 0, 0, 1);
		}
	
		.totalPrice {
			font-size: 26rpx;
			font-family: DIN Next LT Pro-Medium;
			font-weight: 500;
			color: rgba(253, 70, 62, 1);
		}
	
		.copy {
			width: 160rpx;
			height: 101rpx;
			line-height: 101rpx;
			text-align: center;
			background: #FF8505;
			border-radius: 53rpx 0 0 53rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #ffffff;
		}
	
		.settlement {
			width: 145rpx;
			height: 101rpx;
			line-height: 101rpx;
			text-align: center;
			background: #FFB800;
			border-radius: 0rpx 53rpx 53rpx 0rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #000000;
		}
	}
</style>